﻿using System.Collections.Generic;
using System.Linq;
using NStore.Domain.Violations;

namespace NStore.Domain
{
    public class Product
    {
        private int _id;
        public virtual int Id
        {
            get { return _id; }
            protected set { _id = value; }
        }

        public virtual string Name { get; set; }
        public virtual string Description { get; set; }
        public virtual int Quantity { get; set; }
        public virtual float Price { get; set; }

        public virtual ProductCategory Category { get; set; }

        public virtual ProductValidator Validator { get; set; }

        public virtual bool IsValid()
        {
            return GetRuleViolations().Count() == 0;
        }

        public virtual IEnumerable<RuleViolation> GetRuleViolations()
        {
            return Validator.GetRuleViolations(this);
        }
    }
}
